# -*- encoding: utf-8 -*-
"""

PyCharm 07axvspan函数的额使用
2024年10月27日11时58分
by wenyang

文件主要内容:


"""
import numpy as np
import matplotlib.pyplot as plt



def main():
    Fs = 10
    x = np.arange(1, 10, 1 / Fs)
    y = np.random.randn(x.size)
    plt.xlim(1, 8)
    plt.ylim(-1, 1)
    plt.xlabel("Time(s)")
    plt.ylabel("Amplitude")
    plt.axhline(y = 0.5, color = "r")
    plt.axvline(x = 4.5, color = "g")
    plt.axvspan(xmin = 2, xmax = 6, facecolor = "pink", alpha = 0.5)
    plt.axhspan(ymin = 0.2, ymax = 0.8, facecolor = "yellow", alpha = 0.5)
    plt.plot(x, y, ls = "dotted", lw = 2, color = "b", label = "random data")
    plt.legend()
    plt.show()



if __name__ == "__main__":
    main()
